// ignore_for_file: constant_identifier_names, avoid_print


import 'package:airbnb_clone/internal/http/request/article_create_request.dart';

import '../../../models/response.dart';
import '../core/hi_net.dart';
import '../request/base_request.dart';


/// 与服务端通信 , 数据交互和持久化的操作都放在 DAO 层:
class ArticleCreateDao {
  static create(String title, String articleContext) async {
    return await _send(title, articleContext);
  }

  static _send(String title, String articleContext,
      {String belong = "吧",
      String imgurls =
          "[‘https://t.mwm.moe/pc/’,‘https://t.mwm.moe/pc/]"}) async {
    BaseRequest request;
    // 登录请求
    request = ArticleCreateRequest();
    // 为 request 添加参数:
    request
        .addJson("title", title)
        .addJson("article_context", articleContext)
        .addJson("belong", belong)
        .addJson("img_url", imgurls);

    var result = await HiNet.getInstance().fire(request);
    // print("article_create_dao: $result");
    TiebaResponse response = TiebaResponse.fromMap(result);
    return response;
  }
}
